package j2025.j05;

/**
 * @Author 猫大仙
 */
public class j0518 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length,n = matrix[0].length;
        int left = 0,right = m*n-1;
        while(left <= right){
            int mid = (right-left)/2+left;
            int tmp = matrix[mid/n][mid%n];
            if(tmp == target){
                return true;
            }else if(tmp < target){
                left = mid+1;
            }else {
                right = mid-1;
            }
        }
        return false;
    }
}
